package com.hhkj.admin.question.common.utils;

import cn.hutool.core.collection.CollectionUtil;
import com.hhkj.admin.question.model.req.QuestionReq;
import com.hhkj.admin.question.model.res.QuestionRes;

import java.util.List;

/**
 * QuestionListUtils
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/5/25 17:29
 */
public class QuestionListUtils
{

    /**
     * 计算题目组数量信息
     *
     * @param questionGroupList 题目组列表
     * @return 题目数量
     */
    public static Integer countGroupResAmount(List<QuestionRes> questionGroupList)
    {
        int amount = 0;
        for (QuestionRes questionGroup : questionGroupList) {
            if (CollectionUtil.isNotEmpty(questionGroup.getQuestionList())) {
                amount += questionGroup.getQuestionList().size();
            } else {
                amount++;
            }
        }
        return amount;
    }

    /**
     * 计算题目组数量信息
     *
     * @param questionGroupList 题目组列表
     * @return 题目数量
     */
    public static Integer countGroupReqAmount(List<QuestionReq> questionGroupList)
    {
        int amount = 0;
        for (QuestionReq questionGroup : questionGroupList) {
            if (CollectionUtil.isNotEmpty(questionGroup.getQuestionList())) {
                amount += questionGroup.getQuestionList().size();
            } else {
                amount++;
            }
        }
        return amount;
    }
}
